//
//  ViewController.swift
//  1.7.Creating, Using, and Customizing Switches with UISwitch
//
//  Created by joker on 15/7/21.
//  Copyright (c) 2015年 joker. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    var mainSwitch: UISwitch!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        mainSwitch = UISwitch(frame: CGRect(x: 100, y: 100, width: 0, height: 0))
        mainSwitch.setOn(true, animated: true)
        mainSwitch.addTarget(self, action: "switchIsChanged:", forControlEvents: .ValueChanged)
        mainSwitch.onTintColor = UIColor.redColor()
        mainSwitch.tintColor = UIColor.brownColor()
        mainSwitch.thumbTintColor = UIColor.greenColor()
        
        mainSwitch.center = view.center
        view.addSubview(mainSwitch)
    }
    func switchIsChanged(sender: UISwitch)  {
        println("Sender is = \(sender)")
        if sender.on {
            println("Ths switch is truned on ")
        }else
        {
            println("This switch is truned off")
        }
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
        
    }


}

